<extend name="Public/base" />

<block name="body">
	<!-- 标题栏 -->

	<!-- 

		button a 标签的按钮 需要加入 class="btn btn-default" 
            删除加入 btn-danger 确认加入 btn-success;  
            h2标题后面添加返回的按钮
		
		table 需要添加 class="table table-bordered" 所有的按钮使用 icon; 外部a标签需要添加title=""提示

	 -->

	<div class="main-title">
		<h2>回收站</h2>
	</div>
	<div class="cf">
		<div class="fl">
            <!-- <a class="btn" href="{:U('add?game_id='.$game_id)}">新 增</a> -->
            <button class="btn btn-default ajax-post" url="{:U('changeStatus',array('method'=>'resume'))}" target-form="ids"><i class="glyphicon glyphicon-ok-circle"></i> 启 用</button> 
        </div>

        <!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">
				<select class="" name="game" style="float:left;">
					<option value="">--游戏--</option>
					<volist name="games" id="g">
					<option value="{$key}" <eq name="key" value="$game"> selected</eq>>{$g}</option>
					</volist>
				</select>
				<input type="text" name="title" class="search-input form-control" value="{:I('title')}" placeholder="请输入标题">
				<a class="sch-btn" href="javascript:;" id="search" url="{:U('index')}"><i class="btn-search"></i></a>
			</div>
		</div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table class="table table-bordered">
    <thead>
        <tr>
		<th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
		<th class="">缩略图</th>
		<th class="">视频名称</th>
		<th class="">游戏</th>
		<th class="">视频地址</th>
		<th class="">预览视频</th>
		<th class="">时长</th>
		<th class="">上传时间</th>
		<!--<th class="">描述</th>-->
		<th class="">状态</th>
		<th class="">推荐</th>
		<th class="">操作</th>
		</tr>
    </thead>
    <tbody>
		<notempty name="_list">
		<volist name="_list" id="vo">
		<tr>
            <td width="2%"><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
			<td width="13%"><div class="upload-img-box">
                <notempty name="vo.thumb">
                    <div class="upload-pre-item"><img src="{:url_format($vo['thumb'])}"/></div>
                </notempty>
                </div></td>
			<td width="15%">{$vo.full_title|default=$vo['title']|htmlspecialchars_decode} </td>
			<td width="10%">{$games[$vo['game_id']]}</td>
			<td >
				<notempty name="vo.uri">
					<a target="_blank" class="js-pre-video" href="{$vo.uri|url_format}"><i class="glyphicon glyphicon-play-circle"></i> 视频预览</a>
					<a href="{:U('delOssSource?file='.$vo['uri'])}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
				</notempty>
			</td>
			<td >
				<notempty name="vo.pre_uri">
					<a target="_blank" class="js-pre-video" href="{$vo.pre_uri|url_format}"><i class="glyphicon glyphicon-play-circle"></i> 视频预览</a>
					<a href="{:U('delOssSource?file='.$vo['uri'])}" class="confirm ajax-get btn btn-danger btn-xs"><i class="glyphicon glyphicon-trash"></i></a>
				</notempty>
			</td>
			<td >
				{$vo.time|default=0}
			</td>
			<td >
				{$vo.create_time|date="Y-m-d",###}
			</td>
			<!-- <td>{$vo.detail}</td> -->
			<td >
				{$vo.status_text}
			</td>
			<td >
				{$vo.recommend_text}
			</td>
			<td>
				<a class="btn btn-default btn-xs" title="编辑" href="{:U('edit?game_id='.$game_id.'&id='.$vo['id'])}"><i class="glyphicon glyphicon-pencil"></i></a> 
            </td>
		</tr>
		</volist>
		<else/>
		<td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
		</notempty>
	</tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
    <div id="video-pre">
        <video controls="controls" autoplay="autoplay"></video>
    </div>
</block>

<block name="script">
	<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

	<script type="text/javascript">
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');

        var game  = $('.search-form').find('select').serialize();
        game = game.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        game = game.replace(/^&/g,'');

        if( url.indexOf('?')>0 ){
            url += '&' + query + '&' + game;
        }else{
            url += '?' + query + '&' + game;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    highlight_subnav('{:U('trash')}');
    //视频预览
    $('.js-pre-video').on('click',function(){
        var url=$(this).attr('href');
        // alert(url);
        $('#video-pre').addClass('show').find('video').attr('src',url);
        return false;
    })
    $('video').click(function(e){
        return false;
    })
    $('#video-pre').click(function(){
        $(this).find('video').attr('src','');
        $(this).removeClass('show');
    })
	</script>
</block>
